﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using Sharp.Portal.Mvc.List;


namespace Sharp.Portal.Mvc
{
    /// <summary>
    /// 查询项扩展方法
    /// </summary>
    public static class QueryItemExtension
    {
        /// <summary>
        /// 查询默认值
        /// </summary>
        /// <param name="item">查询项</param>
        /// <param name="defaultValue">值</param>
        /// <returns></returns>
        public static QueryItem QueryDefaultValue(this QueryItem item, object defaultValue)
        {
            item.QueryDefaultValue = defaultValue;
            return item;
        }

        /// <summary>
        /// 标题
        /// </summary>
        /// <param name="column"></param>
        /// <param name="text"></param>
        /// <returns></returns>
        public static QueryItem Text(this QueryItem column, string text)
        {
            column.Text = text;
            return column;
        }

        /// <summary>
        /// 搜索哪个字段
        /// </summary>
        /// <param name="column"></param>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        public static QueryItem SearchFor(this QueryItem column, string fieldName)
        {
            column.SearchFor = fieldName;
            return column;
        }

        public static QueryItem DisplayField(this QueryItem column, string displayField)
        {
            column.DisplayField = displayField;
            return column;
        }

        public static QueryItem ValueField(this QueryItem column, string valueField)
        {
            column.ValueField = valueField;
            return column;
        }

        public static QueryItem IsTree(this QueryItem column, bool istree)
        {
            column.IsTree = istree;
            return column;
        }
    }
}